/*
 * This class is used for converting the QueryParser.xml
 * After the xml is parsed, this contians the keywords in the SQL query
 */
package com.querie.parser;

/**
 *
 * @author a-skoshy
 */
public class Keyword implements Comparable<Keyword>{

    private String keyword;
    private int order;
    private String regexp;

    public Keyword() {
    }

    public int compareTo(Keyword obj) throws ClassCastException {
        int otherOrder = obj.getOrder();

        if (this.order < otherOrder) {
            return -1;

        } else if (this.order > otherOrder) {
            return 1;
        } else {
            return 0;
        }
    }

    public int getOrder() {
        return order;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public void setOrder(String o) throws NumberFormatException {

        System.out.println(o);
        this.order = Integer.parseInt(o);
    }

    public void setRegexp(String regexp) {
        this.regexp = regexp;
    }

    public String getKeyword() {
        return keyword;
    }

    public String getRegexp() {
        return regexp;
    }

    public String toString() {
        return keyword + " " + order + regexp;
    }
}
